package com.weixin.xplore.controller;

import com.weixin.xplore.config.CommonResult;
import com.weixin.xplore.controller.domain.request.AuthAccountAutoLoginRequest;
import com.weixin.xplore.controller.domain.request.AuthAccountRegisterRequest;
import com.weixin.xplore.controller.domain.request.AuthAccountSendCheckCodeRequest;
import com.weixin.xplore.controller.domain.request.SysUserUpdateBasicInfoRequest;
import com.weixin.xplore.controller.domain.response.SysUserGetLoginUserVO;
import com.weixin.xplore.dao.entity.SysUser;
import com.weixin.xplore.service.SysUserBizService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys_user")
@RequiredArgsConstructor
public class SysUserController {

    private final SysUserBizService sysUserBizService;
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "发送短信获取校验码")
    @PostMapping("/auth/c/sendCheckCode")
    public CommonResult<Boolean> sendCheckCode(@RequestBody @Valid AuthAccountSendCheckCodeRequest authAccountPasswordLoginParam, @RequestHeader("productCode")String productCode) {
        return CommonResult.data(sysUserBizService.sendCheckCode(authAccountPasswordLoginParam));
    }
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "注册")
    @PostMapping("/auth/c/register")
    public CommonResult<String> register(@RequestBody @Valid AuthAccountRegisterRequest authAccountPasswordLoginParam, @RequestHeader("productCode")String productCode) {
        return CommonResult.data(sysUserBizService.register(authAccountPasswordLoginParam));
    }
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "登陆")
    @PostMapping("/auth/c/login")
    public CommonResult<String> login(@RequestBody @Valid AuthAccountAutoLoginRequest authAccountPasswordLoginParam) {
        return CommonResult.data(sysUserBizService.login(authAccountPasswordLoginParam));
    }
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "获取登陆信息")
    @PostMapping("/get_login_user")
    public CommonResult<SysUserGetLoginUserVO> getLoginUser() {
        return CommonResult.data(sysUserBizService.getLoginUser());
    }
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "修改基本信息")
    @PostMapping("/updae_basic_info")
    public CommonResult<Boolean> updateBasicInfo(@RequestBody SysUserUpdateBasicInfoRequest sysUser) {
        return CommonResult.data(sysUserBizService.updateBasicInfo(sysUser));
    }
    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @Operation(summary = "签到")
    @PostMapping("/sign/in")
    public CommonResult<Boolean> signIn() {
        return CommonResult.data(sysUserBizService.signIn());
    }
}
